package com.acwing.partition2;

import java.io.*;
import java.util.Arrays;
import java.util.Comparator;

/**
 * @author `RKC`
 * @date 2022/1/1 15:36
 */
public class AC165小猫爬山 {

    private static final int N = 20;
    private static int[] weight = new int[N], sum = new int[N];
    private static int maxWeight = 0, n = 0, answer = N;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] s = reader.readLine().split("\\s+");
        n = Integer.parseInt(s[0]);
        maxWeight = Integer.parseInt(s[1]);
        for (int i = 0; i < n; i++) weight[i] = Integer.parseInt(reader.readLine());
        init();
        dfs(0, 0);
        writer.write(answer + "\n");
        writer.flush();
    }

    private static void init() {
        //优化搜索顺序
        Arrays.sort(weight, 0, n);
        for (int i = 0; i < n / 2; i++) {
            int t = weight[i];
            weight[i] = weight[n - i - 1];
            weight[n - i - 1] = t;
        }
    }

    private static void dfs(int catIndex, int k) {
        //最优性剪枝
        if (k >= answer) return;
        if (catIndex == n) {
            answer = k;
            return;
        }
        //尝试把这只猫放在已经启用的车中
        for (int i = 0; i < k; i++) {
            //可行性剪枝
            if (sum[i] + weight[catIndex] <= maxWeight) {
                sum[i] += weight[catIndex];
                dfs(catIndex + 1, k);
                sum[i] -= weight[catIndex];
            }
        }
        //新开一辆车
        sum[k] = weight[catIndex];
        dfs(catIndex + 1, k + 1);
        sum[k] = 0;
    }
}
